package com.baizhi.webController;

import com.baizhi.entrty.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("appUser")
public class UserWebController {

    @Autowired
    private UserService us;

    @GetMapping("showUser/{userId}")
    public User showUser(@PathVariable("userId") int userId){
        User user = us.showUser(userId);
        return user;
    }

    @PostMapping("update")
    public Map update(int userId,String userImage,String userName){
        Map map = new HashMap();
        try {
            us.update(userId,userImage,userName);
            map.put("state",true);
        } catch (Exception e) {
            map.put("state",false);
            e.printStackTrace();
        }
        return map;
    }
}
